<template>
  <a-card :bordered="false">

    <!-- 操作按钮区域 -->
    <div class="table-operator">
     
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('wms_check')">导出</a-button> -->
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-button @click="handleAdd()" type="primary">新增</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
          <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        :rowKey="record=>record.id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleExport(record)">导出</a>
              </a-menu-item>
              <a-menu-item>
                <a @click="handleEdit(record)">编辑</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>

    <dms-implant-detail-modal ref="modalForm" @ok="modalFormOk"></dms-implant-detail-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import DmsImplantDetailModal from './modules/DmsImplantDetailModal.vue'
import { mapState } from 'vuex'
export default {
  name: 'WmsCheckList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    DmsImplantDetailModal,
  },
  data() {
    return {
      description: 'wms_check管理页面',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '医生姓名',
          dataIndex: 'doctorName',
          width: 80,
          align: 'center',
        },
        {
          title: '医院ID',
          align: 'center',
          dataIndex: 'hospitalId',
        },
        {
          title: '产品组',
          align: 'center',
          dataIndex: 'spart',
        },
        {
          title: '销售组织',
          align: 'center',
          dataIndex: 'vkorg',
        },
        {
          title: '状态',
          align: 'center',
          customRender: function (t, r) {
            return r.state == 0 ? '未上报' : r.state == 1 ? '上报失败' : '上报成功'
          },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/wms/implant/list',
        delete: '/wms/implant/delete',
        deleteBatch: '/wms/implant/deleteBatch',
        exportXlsUrl: 'wms/implant/exportXls',
        importExcelUrl: 'wms/implant/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    // this.getSuperFieldList()
    this.$store.commit('getImplantList')
  },
  computed: {
    ...mapState({
      implant: (s) => s.dictionary.enableWarehouse,
    }),
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
    handleExport(e) {
      // console.log('handleExport', e)
      this.handleExportXls('wms_check_' + e.checkNo, { id: e.id, field: '' })
    },
    handleWarehourse(e) {
      const row = this.enableWarehouse[e.warehourse]
      if (row) {
        return row.text
      } else {
        return ''
      }
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'doctorName', text: '医生姓名' })
      fieldList.push({ type: 'string', value: 'hospitalId', text: '医院ID' })
      fieldList.push({ type: 'string', value: 'spart', text: '产品组' })
      fieldList.push({ type: 'string', value: 'vkorg', text: '销售组织' })
      fieldList.push({ type: 'string', value: 'state', text: '状态' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
